package com.ruoyi.project.dict.materialTopic.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.dict.materialTopic.domain.MaterialTopic;
import com.ruoyi.project.dict.materialTopic.mapper.MaterialTopicMapper;
import com.ruoyi.project.dict.materialTopic.service.IMaterialTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 资料专题Service业务层处理
 *
 * @author shixiangwen
 * @date 2022-02-24
 */
@Service
@DataSource(DataSourceType.DICT)
public class MaterialTopicServiceImpl implements IMaterialTopicService {
    @Autowired
    private MaterialTopicMapper materialTopicMapper;

    /**
     * 查询资料专题
     *
     * @param topicId 资料专题ID
     * @return 资料专题
     */
    @Override
    public MaterialTopic selectMaterialTopicById(Long topicId) {
        return materialTopicMapper.selectMaterialTopicById(topicId);
    }

    /**
     * 查询资料专题列表
     *
     * @param materialTopic 资料专题
     * @return 资料专题
     */
    @Override
    public List<MaterialTopic> selectMaterialTopicList(MaterialTopic materialTopic) {
        return materialTopicMapper.selectMaterialTopicList(materialTopic);
    }

    /**
     * 新增资料专题
     *
     * @param materialTopic 资料专题
     * @return 结果
     */
    @Override
    public int insertMaterialTopic(MaterialTopic materialTopic) {
        materialTopic.setCreatedTime(DateUtils.getNowDate());
        return materialTopicMapper.insertMaterialTopic(materialTopic);
    }

    /**
     * 修改资料专题
     *
     * @param materialTopic 资料专题
     * @return 结果
     */
    @Override
    public int updateMaterialTopic(MaterialTopic materialTopic) {
        return materialTopicMapper.updateMaterialTopic(materialTopic);
    }

    /**
     * 删除资料专题对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMaterialTopicByIds(String ids) {
        return materialTopicMapper.deleteMaterialTopicByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除资料专题信息
     *
     * @param topicId 资料专题ID
     * @return 结果
     */
    @Override
    public int deleteMaterialTopicById(Long topicId) {
        return materialTopicMapper.deleteMaterialTopicById(topicId);
    }
}
